package com.xlhj.rabbit.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: caijliu
 * @Date: 01/09/2021 14:54
 * @Description TODO
 * @Vsersion: 0.0.1
 */
@RestController
@RequestMapping("/confirm")
public class ProducerController {

    private static Logger logger = LoggerFactory.getLogger(ProducerController.class);
    private static final String CONFIRM_EXCHANGE_NAME = "confirm.exchange";
    private static final String ROUTING_KEY = "confirmKey";

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("sendMessage/{message}")
    public void sendMessage(@PathVariable String message) {
        CorrelationData correlationData = new CorrelationData("1");
        rabbitTemplate.convertAndSend(CONFIRM_EXCHANGE_NAME, ROUTING_KEY, message + ROUTING_KEY, correlationData);
    }
























}
